package com.fzkj.bio.part4;

import java.net.ServerSocket;
import java.net.Socket;

/**
 * 实现伪异步通信架构
 */
public class Server {
    public static void main(String[] args) {
        try {
            // 1、注册端口
            ServerSocket ss = new ServerSocket(2323);
            // 2、创建线程池对象
            ServerSocketPoolHandler ssp = new ServerSocketPoolHandler(3, 10);
            while(true) {
                Socket s = ss.accept();
                // 把socket封装成可执行的任务对象，传递给线程池处理
                ssp.execute(new ServerRunnbleTarget(s));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
